package org.ar.xmling;

import java.util.ArrayList;
import java.util.List;

import org.ar.xmling.dom.XMLTag;
import org.ar.xmling.dom.processors.XMLTagProcessor;

public class XMLDocument extends XMLTagProcessor {

	public List<XMLTag> tags() {
		return tags;
	}

	public boolean addToTags(XMLTag tag) {
		if (tags != null) {
			return tags.add(tag);
		}
		return false;
	}

	public boolean removeFromTags(XMLTag tag) {
		if (tags != null) {
			return tags.remove(tag);
		}
		return false;
	}

	public List<XMLTag> createTagsList() {
		return tags = new ArrayList<XMLTag>();
	}

	public List<XMLTag> createTagsList(List<XMLTag> tags) {
		return this.tags = tags;
	}

	public String print() {
		StringBuilder result = new StringBuilder();
		for (XMLTag tag : tags) {
			result.append(tag.print());
		}
		return result.toString();
	}
}
